package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CategoryMapper {
    //添加类别
    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    //查询所有
    @Select("SELECT * FROM category order by sort")
    List<Category> findAll();
    //根据id删除
    @Delete("DELETE FROM category WHERE id=#{id}")
    void deleteById(long id);
    @Update("UPDATE category set type=#{type},name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} WHERE id=#{id}")
    void updateById(Category category);
    List<Category> list(@Param("type") Integer type);
    //根据id查找菜品
    @Select("select *from category where id=#{id}")
    Category findById(Long categoryId);
}
